package com.anlogic.sdk.utils;

public class ToolchainUtils {
	// arm toolchain definition
	public static final String GNU_ARM_GCC = "GNU Arm Embedded GCC";
	public static final String GME_ARM_GCC = "GNU MCU Eclipse ARM Embedded GCC";
	public static final String LINARO_AARCH64_GCC = "Linaro AArch64 Linux GNU";
	
	// riscv toolchain definition
	public static final String RISCV_NUCLEI_GCC = "RISC-V Nuclei GCC";
	public static final String RISCV_ANLOGIC_GCC = "RISC-V Anlogic GCC";
	public static final String GME_RISCV_GCC = "GNU MCU RISC-V GCC";
	public static final String RISC_V_GCC_NEWLIB = "RISC-V GCC/Newlib";
	
	public static String getId(String toolchainName) {
		long fUniqueId = Integer.toUnsignedLong(toolchainName.hashCode());
		return Long.toString(fUniqueId);
	}
	
	public static boolean IsLegalToolchain(String toolchainId) {
		if (getId(GNU_ARM_GCC).equals(toolchainId) || getId(GME_ARM_GCC).equals(toolchainId) || getId(LINARO_AARCH64_GCC).equals(toolchainId)) {
			return true;
		}
		if (getId(RISCV_NUCLEI_GCC).equals(toolchainId) || getId(RISCV_ANLOGIC_GCC).equals(toolchainId) || getId(GME_RISCV_GCC).equals(toolchainId) || getId(RISC_V_GCC_NEWLIB).equals(toolchainId)) {
			return true;
		}
		return false;
	}
	
	public static boolean isAArch64Toolchain(String toolchainId) {
		if (getId(GNU_ARM_GCC).equals(toolchainId) || getId(LINARO_AARCH64_GCC).equals(toolchainId)) {
			return true;
		}
		return false;
	}
	
	public static boolean isAArch32Toolchain(String toolchainId) {
		if (getId(GME_ARM_GCC).equals(toolchainId)) {
			return true;
		}
		return false;
	}
	
	public static boolean isRiscvToolchain(String toolchainId) {
		if (getId(RISCV_NUCLEI_GCC).equals(toolchainId) || getId(RISCV_ANLOGIC_GCC).equals(toolchainId) || getId(GME_RISCV_GCC).equals(toolchainId) || getId(RISC_V_GCC_NEWLIB).equals(toolchainId)) {
			return true;
		}
		return false;
	}
}
